<?php
namespace app\we\controller;
use think\Controller;
use app\we\opensdk\Wxmi;

class Open extends Controller{
    /**
     * 微信消息接口入口
     * 所有发送到微信的消息都会推送到该操作
     * 所以，微信公众平台后台填写的api地址则为该操作的访问地址
     * 所有的响应都有机器人响应
     * $this 498944516@qq.com
     */
    private $appid='wxaf7d5d091886b28c';
    private $encodingAesKey='UaFl7MyBKiEV1ETCqAyL3U73ej14fAH90RnBBatWMyV';
    private $token='bookgoal';
    public function index($appid=0){

        //获取配置连接微信
       $options=[
       'appid'=>'wxaf7d5d091886b28c',
       'encodingAesKey'=>'UaFl7MyBKiEV1ETCqAyL3U73ej14fAH90RnBBatWMyV',
       'token'=>'bookgoal',
       ];

        mylog('from open');
        $inputs=input();
        mylog($inputs);

        if (!$inputs)$inputs=Array(
            'signature' => 'd3e18a61ed525b1610c2a2976a037e95dd2adb8e',
            'timestamp' => 1477895048,
            'nonce'=> 787199273,
            'encrypt_type' => 'aes',
            'msg_signature' => 'c9a07cb0cf0e8b6c3cd8e3ea5b1a4a9992161373'
        );
       
        
        mylog($_SERVER);

        $wx = new Wxmi($this->token, $this->encodingAesKey,$this->appId);
        
        $errCode = $wx->decryptMsg($inputs['msg_signature'], $inputs['timestamp'], $inputs['nonce'], $inputs['signature'], $msg='');
        mylog($errCode);
        mylog($msg);
        mylog('end');




       }

   }